#include "timer.h"


/** Program timer (0,1,2) with mode
 */
void timer_init(int timer, int mode)
{
	outportb(TIMER_CTRL, (timer << 6) | mode);
}

/** Load timer (0,1,2) with value
 */
void timer_load(int timer, int value)
{
	int note_freq = TIMER_CLK/value;
	timer_init(timer, LCOM_MODE);
	outportb(timer, LSB(note_freq));
	outportb(timer, MSB(note_freq));
}

void mili_sleep(int mili)
{
	int timeout = mili_tick + mili;
	while(mili_tick < timeout);
}

void sec_sleep(int secs)
{
	int timeout = sec_tick + secs;
	while(sec_tick < timeout);
}

